package com.zp.springcloud.controller;

import com.zp.springcloud.entiies.CommonResult;
import com.zp.springcloud.entiies.Payment;
import com.zp.springcloud.servie.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j  //日志
public class PaymentController {
    @Autowired
    PaymentService paymentService;
    @PostMapping("/payment/create")
    public CommonResult creat(@RequestBody Payment payment){
        int resut = paymentService.creat(payment);
        if (resut > 0){
            return new CommonResult(200,"插入成功",resut);
        }else {
            return new CommonResult(500,"插入失败",null);
        }

    }
    @GetMapping("/payment/get/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Long id){
        Payment paymentById = paymentService.getPaymentById(id);
        log.info("sdf"+paymentById);
        if (paymentById != null){
            return new CommonResult(200,"查询成功",paymentById);
        }else {
            return new CommonResult(500,"查询失败",null);
        }

    }

}
